if(OGRE_FOUND)
    include_directories(
        ${CMAKE_SOURCE_DIR}/lib
        ${CMAKE_CURRENT_BINARY_DIR}
    )

    get_filename_component(TARGET_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)

    set(SOURCES 
        main.cpp
        mainwindow.cpp
        ogrewindow.cpp
        ogrecontext.cpp
        axes.cpp 
        grid.cpp
        roi3d.cpp
        ${DIR_RESOURCES}/easy_apps.qrc
        Easy3D.rc
    )

    add_executable(${TARGET_NAME} ${SOURCES})

    target_link_libraries(${TARGET_NAME} PUBLIC 
        Qt6::Core 
        Qt6::Widgets
	    ${OGRE_LIBRARIES}
        qtcpp
        propertybrowser
    )

    # 生成ogre_config.h
    set(OGRE_MEDIA_DIR "${CMAKE_CURRENT_BINARY_DIR}/media")
    configure_file(
        "${CMAKE_CURRENT_SOURCE_DIR}/ogre_config.h.in"
        "${CMAKE_CURRENT_BINARY_DIR}/ogre_config.h"
    )

    add_custom_command(
        TARGET ${TARGET_NAME} 
        POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/media
        COMMAND ${CMAKE_COMMAND} -E copy_directory
                ${CMAKE_CURRENT_SOURCE_DIR}/media ${CMAKE_CURRENT_BINARY_DIR}/media
    )

    # 关闭调试窗口
    set_target_properties(${TARGET_NAME} PROPERTIES
        WIN32_EXECUTABLE ON
    )

endif()